/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import 'package:flutter/material.dart';
import 'package:hadss_adaptive_layout/hadss_adaptive_layout.dart';

import '../../../l10n/generated/app_localizations.dart';

class Head extends StatefulWidget {
  final WidthBreakpoint screenType;
  final num currentWidth;

  const Head({
    Key? key,
    required this.screenType,
    required this.currentWidth,
  }) : super(key: key);

  @override
  State<Head> createState() => _HeadState();
}

class _HeadState extends State<Head> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return getScreenTypeWidget(
      widget.screenType,
      widget.currentWidth,
    );
  }

  Widget getScreenTypeWidget(screenType, currentWidth) {
    AppLocalizations il8n = AppLocalizations.of(context)!;
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Expanded(
          child: Container(
            margin: const EdgeInsets.only(left: 10,right: 10),
            child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              const Text(
                '消息',
                style: TextStyle(fontWeight: FontWeight.w700, fontSize: 26),
              ),
              Expanded(child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  screenType == WidthBreakpoint.lg || screenType == WidthBreakpoint.xl ? Container(
                    width: 200,
                    height: 40,
                    decoration: BoxDecoration(
                        color: const Color.fromARGB(5, 0, 0, 0),
                        border: Border.all(color: Colors.white60, width: 0.5),
                        borderRadius: BorderRadius.circular(20.0)),
                    child: TextField(
                        decoration: InputDecoration(
                            hintText: il8n.search,
                            prefixIcon:
                            Image.asset('lib/assets/images/s_search.png'),
                            contentPadding:
                            const EdgeInsets.only(top: 4, left: 10),
                            border: InputBorder.none)),
                  ) : Container(
                      padding: const EdgeInsets.all(6),
                      decoration: BoxDecoration(
                          color: const Color(0xFFF3F3F3),
                          borderRadius: BorderRadius.circular(20)
                      ),
                      child: Image.asset('lib/assets/images/search_icon.png')),
                  Container(
                    padding: const EdgeInsets.all(6),
                    margin: const EdgeInsets.only(left: 10),
                    decoration: BoxDecoration(
                        color: const Color(0xFFF3F3F3),
                        borderRadius: BorderRadius.circular(20)
                    ),
                    child: Image.asset('lib/assets/images/plus_circle.png'),),],))
            ],
          ),),
        ),
      ],
    );
  }
}
